<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>剩余参数</title>
  </head>
  <body>
    <script type="text/javascript">
      // const sum = (...args) => {
      // 	let total = 0;
      // 	args.forEach(item => total += item);
      // 	return total;
      // };

      // console.log(sum(10, 20));
      // console.log(sum(10, 20, 30));

      const sum = (...a) => {
        let total = 0;
        a.forEach((i) => (total += i));
        return total;
      };
      console.log(sum(10, 20));
      console.log(sum(10, 20, 30));

      // let ary1 = ['张三' , '李四', '王五'];
      // let [s1, ...s2] = ary1;
      // console.log(s1)
      // console.log(s2)
    </script>
  </body>
</html>
